package com.chen.priority;

public class TestPriority {

    public static void main(String[] args) {

        // 主线程默认优先级
        System.out.println(Thread.currentThread().getName() + "==>" + Thread.currentThread().getPriority());

        MyPriority myPriority = new MyPriority();
        Thread a = new Thread(myPriority, "a");
        Thread b = new Thread(myPriority, "b");
        Thread c = new Thread(myPriority, "c");
        Thread d = new Thread(myPriority, "d");
        Thread e = new Thread(myPriority, "e");
        Thread f = new Thread(myPriority, "f");

        // 线程默认优先级
        a.start();

        // 先设置优先级再启动
        b.setPriority(Thread.MAX_PRIORITY);
        b.start();

        c.setPriority(Thread.MIN_PRIORITY);
        c.start();

        d.setPriority(4);
        d.start();

        e.setPriority(7);
        e.start();

        f.setPriority(8);
        f.start();
    }

}

class MyPriority implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "==>" + Thread.currentThread().getPriority());
    }
}
